package com.excellence.controller;

import com.excellence.datamodel.Result;
import com.excellence.pojo.Collection;
import com.excellence.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName CollectionController
 * @Description TODO
 * @date 2024/4/8 11:39
 * @Version 1.0
 */
//@Controller
//@ResponseBody
@RestController
@RequestMapping("/api/collection")
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @DeleteMapping("/deleteByPrimaryKey")
    Result deleteByPrimaryKey(Long id){
        int res = collectionService.deleteByPrimaryKey(id);
        return Result.success(res);
    }
    @PostMapping("/insert")
    Result insert(Collection record){
        int res = collectionService.insert(record);
        return Result.success(res);
    }

    @PostMapping("/insertSelective")
    Result insertSelective(Collection record){
        int res = collectionService.insertSelective(record);
        return Result.success(res);
    }

    @GetMapping("/selectByPrimaryKey")
    Result selectByPrimaryKey(Long id){
        Collection res = collectionService.selectByPrimaryKey(id);
        return Result.success(res);
    }

    @GetMapping("/selectAll")
    Result selectAll(){
        List<Collection> res = collectionService.selectAll();
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKeySelective")
    Result updateByPrimaryKeySelective(Collection record){
        int res = collectionService.updateByPrimaryKeySelective(record);
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKey")
    Result updateByPrimaryKey(Collection record){
        int res = collectionService.updateByPrimaryKey(record);
        return Result.success(res);
    }

}
